{extend name="Public:public_template" /}
{block name="container"}
<script type="text/javascript">

    //删除上传图片
    function deleteajaxfileupload(That, deleteclassname) {
        $(That).hide();
        $('.' + deleteclassname + '-images').attr('src', "{$images}upload_default.png");
        $('.' + deleteclassname + '-value').val('');
    }

    //上传图片
    function ajaxfileupload(uploadfileid) {
        $.ajaxFileUpload({
            url: "{:url('publicclass/uploadfile')}", //用于文件上传的服务器端请求地址
            secureuri: false, //是否需要安全协议，一般设置为false
            fileElementId: uploadfileid, //文件上传域的ID
            dataType: 'json', //返回值类型 一般设置为json
            success: function (data, status) {
                //服务器成功响应处理函数
                try {
                    if (data.status == 'success') {
                        $('.upload-default-images').attr('src', data.data.imagesurl);
                        $('.upload-default-value').val(data.data.imagesurl);
                        $('.close-upload').show();
                    } else {
                        alert(data.message);
                    }
                } catch (e) {
                    alert(e);
                }
            },
            error: function (data, status, e) {
                //服务器响应失败处理函数
                alert(e);
            }
        });
    }
</script>
<div class="main-container">
    <div class="current-location">{include file="public/current_location" /}</div>
    <div class="content-container" style="margin-bottom: 10px;">
        <form action="{$addurl}" method="post">
            <input type="hidden" name="__token__" value="{$Request.token}"/>
            <input type="hidden" name="where[id]" value="{$findService['id']}"/>
            <input type="hidden" name="info[scroll_column_id]" value="{$scroll_column_id}"/>
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <td class="td-width-15">标题：</td>
                    <td class="text-align"><input type="text" name="info[title]" value="{$findService['title']}" placeholder="请输入标题"/><span class="red">*</span></td>
                </tr>
                <tr>
                    <td class="td-width-15">URL：</td>
                    <td class="text-align"><input type="text" name="info[url]" value="{$findService['url']}" placeholder="请输入URL"/><span class="red">*</span></td>
                </tr>
                <tr>
                    <td class="td-width-15">排序：</td>
                    <td class="text-align"><input type="text" name="info[list_order]" value="{$findService['list_order']}" placeholder="请输入排序序号" class="list-order"/></td>
                </tr>
                <tr>
                    <td class="td-width-15">图片：</td>
                    <td class="text-align">
                        <div class="uploadcontainer">
                            <div class="uploadcontainerimages">
                                <span class="close-upload" {if condition="$findService['id']"}style="display: block"{/if} onclick="return deleteajaxfileupload(this,'upload-default')">删除图片</span>
                                <label>
                                    <img class="upload-default-images" src="{$findService['thumb']}"/>
                                    <input type="hidden" name="info[thumb]" value="{$findService['thumb']}" class="upload-default-value"/>
                                    <input type="file" id="uploadfileid" onchange="return ajaxfileupload('uploadfileid')" class="upload-default-file" name="thumb"/>
                                </label>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
            <div class="submit-button-form"><input type="submit" name="submit" value="提交数据"></div>
        </form>
    </div>
    <div class="content-container">
        <table cellpadding="0" cellspacing="0">
            <tr>
                <th width="5%">序号</th>
                <th width="25%">标题名称</th>
                <th width="20%">URL</th>
                <th width="10%">图片</th>
                <th width="10%">排序</th>
                <th width="10%">添加时间</th>
                <th width="10%">操作</th>
            </tr>
            {if condition="$list"}
            {volist name="list" id="vo"}
            <tr>
                <td>{$vo['orderkey']}</td>
                <td>{$vo['title']}</td>
                <td>{$vo['url']}</td>
                <td><a href="{$vo['thumb']}" target="_blank"><img src="{$vo['thumb']}" /></a></td>
                <td>{$vo['list_order']}</td>
                <td>{$vo['inputtime']}</td>
                <td>
                    <a href="{$vo['updateurl']}">编辑</a>
                    <a href="{$vo['deleteurl']}" class="delete">删除</a>
                </td>
            </tr>
            {/volist}
            {else}
            <tr>
                <td colspan="10">没有数据哦...</td>
            </tr>
            {/if}
        </table>
        <div class="bottom-pages">
            <div class="bottom-pages-button"></div>
            <div class="pages">{$pages}</div>
        </div>
    </div>
</div>
{/block}